package com.moons.demo.aicamera.facerecognition;

import android.app.Application;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;

import com.moons.demo.aicamera.facerecognition.config.DemoConfig;
import com.moons.demo.aicamera.facerecognition.model.DaoMaster;
import com.moons.demo.aicamera.facerecognition.model.DaoSession;

public class BaseApplication extends Application {
    private static BaseApplication instance;
    private DaoSession daoSession;

    public static Context getContext() {
        return instance;
    }

    public static BaseApplication getInstance() {
        return instance;
    }

    @Override
    public void onCreate() {
        super.onCreate();
        instance = this;
        DaoMaster.DevOpenHelper helper = new DaoMaster.DevOpenHelper(getApplicationContext(), DemoConfig.DATABASE_NAME);
        SQLiteDatabase db = helper.getWritableDatabase();
        DaoMaster daoMaster = new DaoMaster(db);
        daoSession = daoMaster.newSession();
    }

    public DaoSession getDaoSession() {
        return daoSession;
    }
}
